package com.strive.demo.web.design.service;

import java.util.Objects;
import java.util.ServiceLoader;

/**
 * @description:
 * @author: bingcun.chen
 * @Date: 2022/6/10 16:48
 * @Version 1.0
 */
public class TypeFactory {
    public static void invoke(String type){
        ServiceLoader<JsonService> loader = ServiceLoader.load(JsonService.class);
        loader.forEach(ns->{
            if(Objects.equals(type,ns.getType())){
                ns.doSomething();
            }
        });
    }

    public static void main(String[] args) {
        invoke("pson");
    }

}
